<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<!-- .breadcrumb -->
	</div>

	<div class="page-content">
		<div class="row">
			<div class="page-header">
				<h1>订单列表</h1>
			</div>
            
	        <div class="col-md-12 col-sm-12 col-xs-12 form">
	        <form action="<?php echo base_url().'admin/order/query'?>" method="get">
	        	<div class="row">
	        	    <div class="wh">
                	<label>订单编号：</label>
                    <input type="text" name="order_no" value="<?php if (isset($order_no)) echo $order_no;?>"/>
                    </div>
                    <div class="wh">
                	<label>手机号码：</label>
                    <input type="text" name="user_phone" value="<?php if (isset($user_phone)) echo $user_phone;?>"/>
                    </div>
                   
                    <div class="wh">
                	<label>订单状态：</label>
                    	<select name="status" id="status">
                    		<option value="-1" <?php if (empty($status)||(!empty($status)&&$status ==-1))echo "selected";?>>全部</option>
                    		<option value="0" <?php if (isset($status)&&$status ==0)echo "selected";?>>未支付</option>
                    		<option value="6" <?php if (isset($status)&&$status ==6)echo "selected";?>>已支付</option>
                            <option value="7" <?php if (isset($status)&&$status ==7)echo "selected";?>>已退款</option>
                    		
                    	</select>
                    </div>
                    <div class="wh">
                	<label>支付方式：</label>
                    	<select name="payment_id" id="payment_id" >
                    		<option value="">全部</option>
                    	
                            <option value="8" <?php if (isset($payment_id)&&$payment_id == '8')echo "selected";?>>钱包支付</option>
                    		<option value="3" <?php if (isset($payment_id)&&$payment_id == '3')echo "selected";?>>微信公众号支付</option>
                    		<option value="6" <?php if (isset($payment_id)&&$payment_id == '6')echo "selected";?>>支付宝APP支付</option>
                    		<option value="7" <?php if (isset($payment_id)&&$payment_id == '7')echo "selected";?>>微信APP支付</option>
							<option value="9" <?php if (isset($payment_id)&&$payment_id == '9')echo "selected";?>>小程序支付</option>
                    	</select>
                    </div>
                    <div class="wh">
                	<label>车牌号：</label>
                    <input type="text" name="car_card" value="<?php if (isset($car_card)) echo $car_card;?>"/>
                    </div>
                    
                    
                    <div class="wh">
                	<label>时间：</label>
                    <input type="text" name="start_time" id="start_time" style="width:100px;" value="<?php if (isset($start_time)) echo $start_time;?>"/>到
                    <input type="text" name="end_time" id="end_time" style="width:100px;" value="<?php if (isset($end_time)) echo $end_time;?>"/>
                    </div>
                    
                    <input type="hidden" name="export"  value="0" id="export" />
                    <div class="col-xs-4 sell_btn" style="width:180px;">
    	        	<button class="btn btn-sm btn-info" type="submit" onclick="javascript:$('#export').val(0);$('form').submit();"><i class="icon-search"></i>查询</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    	            <button class="btn btn-sm btn-info" type="submit" onclick="javascript:$('#export').val(1);$('form').submit();"><i class="icon-search"></i>导出</button>
	                </div>     
	            </div>
	            
	        </div>
	        
	        </form>

        	<div class="col-xs-12 margin_t margin_b">
				<div class="table-responsive  tab">
				<form action="<?php echo base_url()."admin/order/del_some"?>" method="post" id="delForm" style="overflow-x: scroll;">
					<table id="sample-table-1" class="table table-striped table-bordered table-hover" style="width:1300px;">
						<thead>
							<tr>
								<th class="center" style="width: 3%;">
									<label>
										<input type="checkbox" class="ace" />
										<span class="lbl"></span>
									</label>
								</th>
								<th>订单编号</th>
                                <th>手机号码</th>
                                <th>车牌号</th>
                               
                                <th>支付方式</th>
                                <th>第三方</th>
                                <th>支付状态</th>
                                <th>油站降幅</th>
                                <th>钉铛降幅</th>
                                <th>服务费</th>
                                <th>附加费</th>
                                <th>实付金额</th>
                                <th>机显金额</th>
                                <th>优惠券</th>
                                <th>油站</th>
                                <th>下单时间</th>
                                <th>操作</th>
							</tr>
						</thead>

						<tbody>
							<?php if (isset($result)&&count($result)>0){
                            	foreach ($result as $app){
                            	?>
							<tr>
								<td class="center">
                                	<p>
									<label>
										<input type="checkbox" class="ace" name="num[]" value="<?php echo $app->id;?>"/>
										<span class="lbl"></span>
									</label>
                                    </p>
								</td>
								<td><p><?php echo $app->order_no;?></p></td>
                                <td><p><?php echo $app->user_phone;?></p></td>
                                <td><p><?php echo $app->car_card;?></p></td>
                                
                                <td><p><?php  $out = !empty($app->qiao_coupon)? $app->payment.'(壳牌公众号)' : $app->payment;
                                            echo $out;
                                ?></p></td>
                                <td><?php echo $app->third_name;?></td>
                                <td><p><?php
											if($app->status==7){
												echo '已退款';
											}elseif($app->status == 0){
												echo "未支付";
											}elseif($app->status == 6){
												echo "已支付";
											}
											?></p>
                                </td>
                                <td><p>
                                <?php if($app->zhe_price != 0):?>
								<?php echo $app->machine_price-$app->zhe_price;?>
                                <?php else:?>
                                0.00
                                <?php endif;?>
                                </p></td>
                                <td><p><?php echo round(($app->yz_price-$app->dd_price)*$app->oil_liters,2);?></p></td>
                                <td><p><?php echo $app->fuwu_price?></p></td>
                                <td><p><?php echo $app->fujia?></p></td>
                            	<td><p><?php echo $app->order_price?></p></td>
                                <td><p><?php echo $app->machine_price?></p></td>
                            	<td><p><?php echo $app->coupon_price?></p></td>
                            	<td><p><?php echo $app->gas;?></p></td>
                                <td><p><?php echo $app->create_time;?></p></td>
                                <td><p>
	                               
						
	                                    <a href="javascript:void(0)" onclick="cancelmodal('<?php echo $app->id;?>')" data-toggle="modal" class="btn btn-danger btn-sm"><i class="icon-trash"></i>取消</a>
	                                    <!-- <a href="javascript:void(0)" onclick="delmodal('<?php echo $app->id;?>')" data-toggle="modal" class="btn btn-danger btn-sm"><i class="icon-trash"></i>删除</a> -->
                                    </p>
                                </td>
    						</tr>
    						<?php }
                            }else{?>
                            <tr>
                            	<td colspan="15">无数据</td>
                            </tr>
                            <?php }?>
						</tbody>
					</table>
					</form>
				</div><!-- /.table-responsive -->
			</div>
        
        	<div class="col-sm-12">
            	<div class="modal-footer no-margin-top">
                	<div class="pull-left record">
						共<?php echo $count;?>条记录
                    </div>
            		<?php if (isset($page))echo $page;?>
            	</div>
            </div>
		</div><!-- /.row -->
	</div><!-- /.page-content -->
</div><!-- /.main-content -->
<div id="delsomeModal" class="modal fade" role="dialog" aria-hidden="true">
	<div class="modal-dialog" style="width: 300px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>提示信息</h3>
			</div>
			<div class="modal-body">
			  <p>删除后将无法恢复，确定要删除所选订单吗？</p>
			</div>
			<div class="modal-footer">
			  <button id="delsomebtn" type="button" class="btn btn-danger">确定</button>
			  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
			</div>
		</div>
	</div>
</div>
<div id="cancelModal" class="modal fade" role="dialog" aria-hidden="true">
	<div class="modal-dialog" style="width: 300px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>提示信息</h3>
			</div>
			<div class="modal-body">
			  <p>取消订单后将无法恢复，已支付的金额会直接退回用户支付账户<br>确定要取消所选订单吗？</p>
			</div>
			<div class="modal-footer">
			  <input type="hidden" id="cancel_order_id" value="">
			  <a id="cancelbtn" href="#" onclick="cancel()" class="btn btn-danger">确定</a>
			  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
			</div>
		</div>
	</div>
</div>
<div id="completeModal" class="modal fade" role="dialog" aria-hidden="true">
	<div class="modal-dialog" style="width: 300px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>提示信息</h3>
			</div>
			<div class="modal-body">
			  <p>完成订单后，订单金额会发放到车主钱包<br>确定要完成该订单吗？</p>
			</div>
			<div class="modal-footer">
			  <input type="hidden" id="complete_order_id" value="">
			  <a id="completebtn" href="#" onclick="complete()" class="btn btn-danger">确定</a>
			  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
function delSomeModal(){
	if(checkSelect()){
    	$('#delsomeModal').modal('show');
	}else{
		alert('请选择正确的记录进行删除');
	}
}
$("#delsomebtn").click(function(){
	$("#delForm").submit();
});
function cancelmodal(id){
	$("#cancel_order_id").val(id);
    $('#cancelModal').modal('show');
}
function completemodal(id){
	$("#complete_order_id").val(id);
    $('#completeModal').modal('show');
}
function complete(){
	$('#completeModal').modal('hide');
	showLoading('确认完成中...');
	$.ajax( {
        url:'<?php echo site_url("admin/order/complete")?>',
        data:{order_id:$('#complete_order_id').val()},
        type:'post',
        cache:false,
        dataType:'json',    
        success:function(result) {
        	hideLoading();
        	if(result.ret == '200'){
            	if(result.data.code == '0'){
            		window.location.reload();
            	}else{
            		alert("确认完成失败:"+result.data.msg);
            	}
        		
			}else {
				alert("确认完成失败:"+result.msg);
			}
        },
        error : function() {
        	hideLoading();       
			alert("error");
        }
	});
}
function cancel(){
	$('#cancelModal').modal('hide');
	showLoading('取消中...');
	$.ajax( {
        url:'<?php echo site_url("admin/order/cancel")?>',
        data:{order_id:$('#cancel_order_id').val()},
        type:'post',
        cache:false,
        dataType:'json',    
        success:function(result) {
        	hideLoading();
        	if(result.ret == '200'){
            	if(result.data.code == '0'){
            		window.location.reload();
            	}else{
            		alert("取消失败:"+result.data.msg);
            	}
        		
			}else {
				alert("取消失败:"+result.msg);
			}
        },
        error : function() {
        	hideLoading();
			alert("error");
        }
	});
}


layui.use(['form','element','laydate'], function(){
  var form = layui.form,
  	element = layui.element,
  	laydate = layui.laydate;

  //时间选择器
  laydate.render({
    elem: '#start_time'
    ,type: 'datetime'
  });
    //时间选择器
  laydate.render({
    elem: '#end_time'
    ,type: 'datetime'
  }); 


});


</script>
	